home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NETWORK.SWG / 0008_Novell File Locking.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  2KB  |  73 lines

  1. {
  2. JEFF SHANNON
  3.  
  4. Novell/File Locking/Sharing
  5.  
  6. > Does anyone have any samples of network File sharing/access code For Turbo
  7. > Pascal/Borland Pascal 6-7.
  8.  
  9. This is from the Advanced Turbo Pascal Techniques book by Chris Ohlsen and
  10. Gary Stroker.  It's For TP 5.5 but I'm sure you could make use of it.
  11.  
  12. Oops, I hope I didn't violate any copyright laws by posting this code.  I
  13. doubt the authors of the book would sue me as it is a FINE book and I
  14. recommend it to all.  Now the publishers are a different story...
  15. }
  16.  
  17. Unit FileLock;
  18.  
  19. Interface
  20.  
  21. Uses
  22.   Dos;
  23.  
  24. Function Lock(Var UnTyped; pos, size : LongInt) : Boolean;
  25. Function UnLock(Var UnTyped; pos, size : LongInt) : Boolean;
  26.  
  27. Implementation
  28.  
  29. Function Lock(Var UnTyped; pos, size : LongInt) : Boolean;
  30. Var
  31.   reg : Registers;
  32.   f   : File Absolute UnTyped;
  33.  
  34. begin
  35.   pos  := pos * FileRec(f).RecSize;
  36.   size := size * FileRec(f).RecSize;
  37.   reg.AH := $5C;
  38.   reg.AL := $00;
  39.   reg.BX := FileRec(f).Handle;
  40.   reg.CX := Hi(pos);
  41.   reg.DX := Lo(pos);
  42.   reg.SI := Hi(size);
  43.   reg.DI := lo(size);
  44.   Intr($21, reg);
  45.   if ((reg.Flags and FCarry) <> 0) then
  46.     Lock := False
  47.   else
  48.     Lock := True;
  49. end;
  50.  
  51. Function UnLock(Var UnTyped; pos, size : LongInt) : Boolean;
  52. Var
  53.   reg : Registers;
  54.   f   : File Absolute UnTyped;
  55. begin
  56.   pos  := pos * FileRec(f).RecSize;
  57.   size := size * FileRec(f).RecSize;
  58.   reg.AH := $5C;
  59.   reg.AL := $01;
  60.   reg.BX := FileRec (f).Handle;
  61.   reg.CX := Hi(pos);
  62.   reg.DX := Lo(pos);
  63.   reg.SI := Hi(size);
  64.   reg.DI := Lo(size);
  65.   Intr($21, reg);
  66.   if ((reg.Flags and FCarry) <> 0) then
  67.     Unlock := False
  68.   else
  69.     Unlock := True;
  70. end;
  71.  
  72. end.
  73.